Skip to content

Conversation

JasonWeinzierl
Copy link
Owner

@JasonWeinzierl JasonWeinzierl commented Nov 26, 2024

BREAKING CHANGE: no-ignored-observable is removed; use no-floating-observables instead.

  • Enhance floating observable logic to handle more than just call expressions.
    • Now that no-ignored-observable is included in the strict config, enhancing it will be more widely useful.
  • Add ignoreVoid option. When false, this rule will reach past the void operator and check its argument. Defaults to true (i.e. void can be used to ignore floating observables).
  • Rename rule from no-ignored-observable to no-floating-observables.
    • As mentioned in Add rule no-misused-observables #43 , we should take advantage of this project being a fork to clarify rule names, and typescript-eslint has an existing convention for promises that would be nice to imitate for observables: one rule covers floating, the other covers misused.
    • An alternative is keeping the old rule as-is and deprecating it. However, this forked project is not v1 yet, so we should take advantage of prerelease to make breaking changes early instead of putting them off for a later, more painful date.

…mance

Previously the selector was `ExpressionStatement > CallExpression`, but in order to support `ignoreVoid`, the selector was broadened to just `ExpressionStatement`.  This could have a performance impact, but re-adding this call expression check should revert to the original performance.
Go back to more limited selectors for performance.  Still checking the expression's type (call or unary) so we don't type-check too early.
Too many existing projects manually enable this rule, so removing it is more impactful than the other proposed changes during prerelease.  This rule will be kept as-is and maybe removed in v2.
@JasonWeinzierl JasonWeinzierl changed the title feat(no-floating-observables): rewrite of no-ignored-observable feat(no-floating-observables)!: replace no-ignored-observable Nov 26, 2024
Copy link

LCOV of commit bc32335 during .github/workflows/ci.yml #153

Summary coverage rate:
  lines......: 96.3% (3747 of 3889 lines)
  functions..: 95.7% (246 of 257 functions)
  branches...: 91.1% (754 of 828 branches)

Files changed coverage rate:
                                         |Lines       |Functions  |Branches    
  Filename                               |Rate     Num|Rate    Num|Rate     Num
  =============================================================================
  src/configs/strict.ts                  | 100%     39| 100%     1| 100%      1
  src/etc/is.ts                          |72.5%    109|66.7%    30| 100%     20
  src/index.ts                           | 100%    103|    -     0|    -      0
  src/rules/no-floating-observables.ts   | 100%     83| 100%     8|85.2%     27

@JasonWeinzierl JasonWeinzierl merged commit 1268dc8 into main Nov 28, 2024
2 checks passed
@JasonWeinzierl JasonWeinzierl deleted the no-floating-observables branch November 28, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant